home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
rjs.lha
/
RJS
/
Transport
/
tests
/
sclient.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-14
|
899b
|
43 lines
#include <iostream.h>
#include <stdio.h>
#include <osfcn.h>
#include <string.h>
#include <libc.h>
#include "RJS/Transport.h"
int main(int argc, char *argv[])
{
char buffer[512];
if (argc!=3) {
cerr << "usage: " << argv[0] << " broadcast_port message" << endl;
exit(1);
}
InetAddress to(InetAddress::Broadcast,atoi(argv[1])),from,local;
InetDatagram server;
server.socket_client();
server.setsockopt(Socket::Broadcast,Socket::On);
server.getsockname(local);
cout << "client: local address is " << local << endl;
cout << "client: message to " << to << endl;
int nbw=server.sendto(argv[2],strlen(argv[2])+1,to); // send to server
cout << "client: sent " << nbw << " bytes"<<endl;
int nbr=server.recvfrom(buffer,512,from);
buffer[nbr]=0;
cout << "client: read ==> '" << buffer << "'" << endl;
cout << "client: from ==> " << from << endl;
exit(0);
}